<template>
  <div>
    <el-button :disabled="(data.classStatus > 1)" type="primary" icon="el-icon-edit" size="small" @click="to">编辑</el-button>
    <eForm ref="form" :teachers="teachers" :courses="courses" :is-add="false"/>
  </div>
</template>

<script>
import eForm from './form'
import { getTeacherListOptions } from '@/api/teacher'
import { listAllCourse } from '@/api/course'

export default {
  components: { eForm },
  props: {
    data: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      teachers: [],
      courses: []
    }
  },
  methods: {
    to() {
      this.getTeachers()
      this.getCourse()
      const _this = this.$refs.form
      _this.addForm = Object.assign({}, this.data)
      _this.dialog = true
    },
    getTeachers() {
      getTeacherListOptions().then(res => {
        this.teachers = res.data
      })
    },
    getCourse() {
      const params = { status: 1 }
      listAllCourse(params).then(res => {
        this.courses = res.data
      })
    }
  }
}
</script>

<style scoped>
div{
  display: inline-block;
  margin-right: 10px;
}
</style>
